package com.allwees.bs.c.module.user.dto;


import com.allwees.bs.c.module.user.entity.ShippingAddressEntity;
import com.allwees.bs.core.model.order.entity.OrderModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
//@ApiModel(description = "收货地址")
public class ShippingAddressDTO implements Serializable {
//    @ApiModelProperty(value = "主键ID")
    private String uuid;

//    @ApiModelProperty(value = "用户uuid")
    private String userUuid;

//    @ApiModelProperty(value = "是否是默认收货地址")
    private Boolean isDefault;

//    @ApiModelProperty(value = "名")
    private String firstName;

//    @ApiModelProperty(value = "姓")
    private String lastName;

//    @ApiModelProperty(value = "国际电话区号")
    private String itu;

//    @ApiModelProperty(value = "电话号码")
    private String phone;

//    @ApiModelProperty(value = "国家")
    private String country;

//    @ApiModelProperty(value = "州/省")
    private String province;

//    @ApiModelProperty(value = "城市")
    private String city;

    //    @ApiModelProperty(value = "国家 id xxx0000")
    private String region;

//    @ApiModelProperty(value = "区号")
    private String zipCode;

//    @ApiModelProperty(value = "地址第一行")
    private String addressLine1;

//    @ApiModelProperty(value = "地址第二行")
    private String addressLine2;

    private String note;

//    @ApiModelProperty(value = "创建时间")
    private Date createdAt;

//    @ApiModelProperty(value = "更新时间")
    private Date updatedAt;

//    @ApiModelProperty(value = "删除时间")
    private Date deletedAt;

    public ShippingAddressDTO(ShippingAddressEntity entity) {
        this.setUuid(entity.getUuid());
        this.setUserUuid(entity.getUserUuid());
        this.setIsDefault(entity.getIsDefault() != null && entity.getIsDefault() == 1);
        this.setFirstName(entity.getFirstName());
        this.setLastName(entity.getLastName());
        this.setItu(entity.getItu());
        this.setPhone(entity.getPhone());
        this.setCountry(entity.getCountry());
        this.setProvince(entity.getProvince());
        this.setCity(entity.getCity());
        this.setZipCode(entity.getZipCode());
        this.setAddressLine1(entity.getAddressLine1());
        this.setAddressLine2(entity.getAddressLine2());
        this.setCreatedAt(entity.getCreatedAt());
        this.setUpdatedAt(entity.getUpdatedAt());
        this.setDeletedAt(entity.getDeletedAt());
        this.setNote(entity.getNote());
    }

    public ShippingAddressDTO(OrderModel order) {
        this.setCountry(order.getShippingAddressCountry())
                .setProvince(order.getShippingAddressProvince())
                .setFirstName(order.getShippingAddressFirstName())
                .setLastName(order.getShippingAddressLastName())
                .setCity(order.getShippingAddressCity())
                .setZipCode(order.getShippingAddressZipCode())
                .setAddressLine1(order.getShippingAddressLine1())
                .setAddressLine2(order.getShippingAddressLine2())
                .setNote(order.getNote())
                .setItu(order.getShippingAddressItu());
    }
}
